﻿import QtQuick 2.0

Rectangle {

    id: root;
    Component.onCompleted: {

        var obj = new Object();

        console.log(obj.toString());
        console.log(obj.constructor);
        console.log(root.hasOwnProperty("width"));
        console.log(Item.isPrototypeOf(root));
        console.log(root.propertyIsEnumerable("children"));
        console.log(root.toString());
        console.log(root.valueOf());


        //动态增加属性
        var person = new Object();
        person.name="123";
        person.id = 110;
        console.log(person.name);
        console.log(person.id);

        //对象的字面量表示方法
        var person = {
            "name": "123",
            "id" : 10
        }

        //动态增加方法

        person.printInfo = function printInfo(){
            console.log("name - ", this.name," year -", this.year );
        }

            person.printInfo();

            //使用数组下标访问属性和方法

            console.log(person["name"]);
            person["printInfo"](); //person.printInfo();

            //通过propertyIsEnumerable() 方法判断对象的属性能不能列举，多数自定义的属性可以列举
            //内置对象或宿主对象的多数核心属性是不能枚举的

            for(var prop in person){

                console.log(prop, ",", person[prop]);
            }
    }




}

